<%@page import="com.entity.Contact"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="top.jsp" %>

<!DOCTYPE HTML>
<html lang="en-US">
<head>
	<meta>
    <title>编辑联系人</title>
    <style type="text/css">
		.h{
			height:30px;
		}
		span{
			color:red;
		}
	</style>
  </head>
  
  <body>
  	
  		<%
  			Contact contact=(Contact)session.getAttribute("contact");
  			String a="";
  		 %>
    
    	<div class="span9" style="width:800px;margin-left:310px">
			<form id="form" class="form-horizontal" action="updatecontact.jspx" method="post">
	        	<fieldset>
		          <legend>编辑联系人</legend>
		          <div style="color:red;padding-left:100px">带*为必填项</div><br>
		          <div class="control-group">
		            <label for="input01" class="control-label">姓名<span>*</span></label>
		            <div class="controls">
		              <input type="text" value="<%=contact.getName() %>" name="contactName" x-webkit-speech="undefined" id="input1" class="span5 h">
		            <span id="input1_msg"></span>
		            </div>
		          </div>
				   <div class="control-group">
		            <label for="input01" class="control-label">公司<span>*</span></label>
		            <div class="controls">
		              <input type="text" value="<%=contact.getCompanyName() %>" name="company" x-webkit-speech="undefined" id="input2" class="span5 h">
		            <span id="input2_msg"></span>
		            </div>
		          </div>
				  <div class="line"></div>
				   <div class="control-group">
		            <label for="input01" class="control-label">手机<span>*</span></label>
		            <div class="controls">
		              <input type="text" value="<%=contact.getMobile() %>" name="mobile" x-webkit-speech="undefined" id="input3" class="span5 h">
		            <span id="input3_msg"></span>
		            </div>
		          </div>
				   <div class="control-group">
		            <label for="input01" class="control-label">固话&nbsp </label>
		            <div class="controls">
		              <input type="text" value="<%=contact.getTel()==a?a:contact.getTel() %>" name="tel" x-webkit-speech="undefined" id="input01" class="span5 h">
		            </div>
		          </div>
				  <div class="control-group">
		            <label for="input01" class="control-label">邮箱<span>*</span></label>
		            <div class="controls">
		              <input type="text" value="<%=contact.getEmail() %>" name="email" x-webkit-speech="undefined" id="input4" class="span5 h">
		            <span id="input4_msg"></span>
		            </div>
		          </div>
				   <div class="line"></div>
				  <div class="control-group">
		            <label for="input01" class="control-label">地址<span>*</span></label>
		            <div class="controls">
		              <input type="text" value="<%=contact.getAddress() %>" name="address" x-webkit-speech="undefined" id="input5" class="span5 h">
		           <span id="input5_msg"></span>
		            </div>
		          </div>
				   <div class="line"></div>
				   <div class="control-group">
		            <label for="input01" class="control-label">主页&nbsp  </label>
		            <div class="controls">
		              <input type="text" value="<%=contact.getWebsite()==a?a:contact.getWebsite() %>" name="website" id="input01" class="span5 h">
					  <p class="help-block">http://www.xxx.com</p>
		            </div>
		          </div>
				   <div class="control-group">
		            <label for="input01" class="control-label">微博&nbsp  </label>
		            <div class="controls">
						<select class="span2" name="weibosite">
							<%
								if(contact.getWeibo()==a){
							 %>
							 	<option></option>
							 	<option value="sina" >新浪微博</option>
								<option value="qq">腾讯微博</option>
								<option value="twitter">Twitter</option>
							<%
								}else if(contact.getWeibo().contains("http://weibo.com/")){
							 %>
								<option value="sina" selected="selected">新浪微博</option>
								<option value="qq">腾讯微博</option>
								<option value="twitter">Twitter</option>
							<%
								}else if(contact.getWeibo().contains("http://t.qq.com/")){
								
							 %>
							 	<option value="sina">新浪微博</option>
								<option value="qq" selected="selected">腾讯微博</option>
								<option value="twitter">Twitter</option>
							 <%
							 	}else{
							  %>
							  	<option value="sina">新浪微博</option>
								<option value="qq">腾讯微博</option>
								<option value="twitter" selected="selected">Twitter</option>
							 <% 
							 	}
							 %>
						</select>
						<div class="input-prepend">
							<span style="color:black" class="add-on">@</span><input value="<%=contact.getWeibo()==a?a:contact.getWeibo().substring(contact.getWeibo().indexOf(".com/")+5) %>" name="weiboname" type="text" x-webkit-speech="undefined" size="16" id="prependedInput" class="span2 h">
		                </div>
						
		            </div>
		          </div>
				   <div class="control-group">
		            <label for="input01" class="control-label">简介&nbsp </label>
		            <div class="controls">
		              <textarea rows="6" class="span5" name="content"><%=contact.getContent()==a?a:contact.getContent() %></textarea>
		            </div>
		          </div>
				  
				  
		
		          <div class="form-actions">
		            <button class="btn btn-primary" type="submit">保存</button>
		            <a href="contact.jspx" class="btn">返回</a>
		          </div>
	        </fieldset>
	      </form>          
          	
		</div>
		<script type="text/javascript">
			document.getElementById("form").onsubmit=function(){
			
			var input1 = document.getElementById("input1").value;
			var input2 = document.getElementById("input2").value;
			var input3 = document.getElementById("input3").value;
			var input4 = document.getElementById("input4").value;
			var input5 = document.getElementById("input5").value;
			

			if(input1.trim() == "") {
				document.getElementById("input1_msg").innerHTML = "请输入联系人姓名";
				document.getElementById("input1").focus();
				return false;
			}
			if(input2.trim() == "") {
				document.getElementById("input2_msg").innerHTML = "请输入联系人公司";
				document.getElementById("input2").focus();
				return false;
			}
			if(input3.trim() == "") {
				document.getElementById("input3_msg").innerHTML = "请输入联系人手机";
				document.getElementById("input3").focus();
				return false;
			}
			if(input4.trim() == "") {
				document.getElementById("input4_msg").innerHTML = "请输入联系人邮箱";
				document.getElementById("input4").focus();
				return false;
			}
			if(input5.trim() == "") {
				document.getElementById("input5_msg").innerHTML = "请输入联系人地址";
				document.getElementById("input5").focus();
				return false;
			}
			
		};
		document.getElementById("input1").onblur = function(){
			var name = document.getElementById("input1").value;
			if(name.trim() == "") {
				
				document.getElementById("input1_msg").innerHTML = "请输入联系人姓名";
				document.getElementById("input1").focus();
			}else{
				document.getElementById("input1_msg").innerHTML = "";
			}
		};
		document.getElementById("input2").onblur = function(){
			var name = document.getElementById("input2").value;
			if(name.trim() == "") {
				
				document.getElementById("input2_msg").innerHTML = "请输入联系人公司";
				document.getElementById("input2").focus();
			}else{
				document.getElementById("input2_msg").innerHTML = "";
			}
		};
		document.getElementById("input3").onblur = function(){
			var name = document.getElementById("input3").value;
			if(name.trim() == "") {
				
				document.getElementById("input3_msg").innerHTML = "请输入联系人手机";
				document.getElementById("input3").focus();
			}else{
				document.getElementById("input3_msg").innerHTML = "";
			}
		};
		document.getElementById("input4").onblur = function(){
			var name = document.getElementById("input4").value;
			if(name.trim() == "") {
				
				document.getElementById("input4_msg").innerHTML = "请输入联系人邮箱";
				document.getElementById("input4").focus();
			}else{
				document.getElementById("input4_msg").innerHTML = "";
			}
		};
		document.getElementById("input5").onblur = function(){
			var name = document.getElementById("input5").value;
			if(name.trim() == "") {
				
				document.getElementById("input5_msg").innerHTML = "请输入联系人地址";
				document.getElementById("input5").focus();
			}else{
				document.getElementById("input5_msg").innerHTML = "";
			}
		};
    	
    	
    	document.getElementById("input1").onkeydown = function(){
			document.getElementById("input1_msg").innerHTML = "";
		};
    	document.getElementById("input2").onkeydown = function(){
			document.getElementById("input2_msg").innerHTML = "";
		};
		document.getElementById("input3").onkeydown = function(){
			document.getElementById("input3_msg").innerHTML = "";
		};
		document.getElementById("input4").onkeydown = function(){
			document.getElementById("input4_msg").innerHTML = "";
		};
		document.getElementById("input5").onkeydown = function(){
			document.getElementById("input5_msg").innerHTML = "";
		};
		</script>
    
  </body>
</html>
